using System;

namespace SMS.SMPPClient.PDU.Incoming
{
    /// <summary>
    /// Defines an outbind response (really a request TO us) from the SMSC.
    /// </summary>
    public class SMPPOutbind : SMPPResponse
    {
        private string _SystemID;
        private string _Password;

        /// <summary>
        /// The ID of the SMSC.
        /// </summary>
        public string SystemID
        {
            get
            {
                return _SystemID;
            }
        }

        /// <summary>
        /// Password that the ESME can use for authentication.
        /// </summary>
        public string Password
        {
            get
            {
                return _Password;
            }
        }

        /// <summary>
        /// Creates an outbind response PDU.
        /// </summary>
        /// <param name="response">The byte response from the
        /// SMSC.</param>
        public SMPPOutbind(byte[] response)
            : base(response)
        {
            DecodeSMSCResponse();
        }

        /// <summary>
        /// Decodes the outbind response from the SMSC.
        /// </summary>
        protected override void DecodeSMSCResponse()
        {
            byte[] remainder = ResponseAfterHeader;
            _SystemID = GetStringFromBody(ref remainder);
            _Password = GetStringFromBody(ref remainder);
            //fill the TLV table if applicable
            tlvTable.TranslateTLVDataIntoTable(remainder);
        }
    }
}
